************************************************************************
*** The Causal Effect of Education on Support for International Trade:  
*** Evidence from Compulsory Education Reforms
*** Omer Solodoch 
*** Replication code 2 
** do file for figures 2, A-7, and A-8
*************************************************************************
clear all
***************************************************************************************************************
**Figure (2) The Effect of Education Across Survey Waves
***************************************************************************************************************

use fig2data.dta
gen min95 = coef-1.96*SE
gen max95 = coef+1.96*SE

 
set scheme s1mono
lab var year "Year"
twoway (scatter coef year if year>=1 & year<=4,  mcolor(black) msize(vlarge)) ///
  (rcap min95 max95 year if year>=1 & year<=4, lcolor(black)  lwidth(thick)),  ///
   legend(off) graphregion(fcolor(white) lcolor(white)) xlab(1 "Pooled" 2 "1995" 3 "2003" 4 "2013", angle(horizontal) valuelabel labsize(large) nogrid) ylab(0(0.02)0.08, nogrid angle(horizontal) labsize(large)) yline(0, lcolor(maroon) lpattern(dash)) yline(0(0.02)0.08, lwidth(thin) lcolor(gs8%30)) ///
  xline(1.5, lcolor(maroon) lpattern(dash)) ///
   xscale(range(0.5 4.5)) xline(1(1)4, lwidth(thin) lcolor(gs8%30)) ///
   yscale(range(-0.01 0.08)) ///
  xlab(, labsize(vlarge)) ytitle("", size(medium)) ytitle("Effect of an additional year of" "schooling on support for trade", color(black) size(vlarge)) xtitle("") 
graph display, ysize(2.5) xsize(5)



clear all
***************************************************************************************************************
** Figure A-7: Compulsory Schooling Effect by Bandwidth
***************************************************************************************************************
use figA7data.dta

**
gen min95_wcov = coef_wcov-1.96*SE_wcov
gen max95_wcov = coef_wcov+1.96*SE_wcov
gen min95_wocov = coef_wocov-1.96*SE_wocov
gen max95_wocov = coef_wocov+1.96*SE_wocov

set scheme s1mono
**panel (a): Without covariates
twoway (scatter coef_wocov bandwidth if bandwidth>=1 & bandwidth<=20, mcolor(black)) ///
  (rcap min95_wocov max95_wocov bandwidth if bandwidth>=1 & bandwidth<=20, vertical lcolor(black)), ///
  legend(off) graphregion(fcolor(white) lcolor(white)) xlab(1(1)20, angle(horizontal) valuelabel labsize(medium) nogrid) ylab(, nogrid) yline(0, lcolor(black) lpattern(dash)) ylab(-0.2(0.1)0.4) ///
  xline(1(1)20, lwidth(thin) lcolor(gs8%30)) yline(-0.2(0.05)0.4, lwidth(thin) lcolor(gs8%30)) ///
  xlab(, labsize(small)) ytitle("", size(small)) ytitle("Effect of compulsory education on support for trade", color(black) size(medium)) xtitle("Bandwidth")

**panel (b): With covariates
  twoway (scatter coef_wcov bandwidth if bandwidth>=1 & bandwidth<=20, mcolor(black)) ///
  (rcap min95_wcov max95_wcov bandwidth if bandwidth>=1 & bandwidth<=20, vertical lcolor(black)), ///
  legend(off) graphregion(fcolor(white) lcolor(white)) xlab(1(1)20, angle(horizontal) valuelabel labsize(medium) nogrid) ylab(, nogrid) yline(0, lcolor(black) lpattern(dash)) ylab(-0.2(0.1)0.4) ///
  xline(1(1)20, lwidth(thin) lcolor(gs8%30)) yline(-0.2(0.05)0.4, lwidth(thin) lcolor(gs8%30)) ///
  xlab(, labsize(small)) ytitle("", size(small)) ytitle("Effect of compulsory education on support for trade", color(black) size(medium)) xtitle("Bandwidth")

clear all
***************************************************************************************************************
** Figure A-8: Country-by-country exclusion
***************************************************************************************************************

use figA8data.dta
gen min95 = coef-1.96*SE
gen max95 = coef+1.96*SE

sort coef
gen sample_id = _n


*CREATE A VALUE LABEL FOR VAR2 FROM THE VALUES OF VAR1
forvalues i = 1/`=_N' {
 label define lab10   `=sample_id[`i']'    "`=sample[`i']'", add
}
label values sample_id lab10

gen exclude = sample!="None"

set scheme s1mono
lab var sample "Excluded country"
lab var sample_id "Excluded country"

separate coef, by(exclude) veryshortlabel
scatter coef? sample_id

*NOW GRAPH USING THE LABELS ON THE AXIS
levelsof sample_id, local(var2values)
twoway (scatter coef? sample_id, mcolor(maroon black) msize(vlarge large)) ///
  (rcap min95 max95 sample_id, vertical lcolor(black)),  ///
  legend(off) graphregion(fcolor(white) lcolor(white)) xlab(1(1)19, angle(horizontal) valuelabel labsize(medium) nogrid) ylab(, nogrid) yline(0, lcolor(black) lpattern(dash)) ylab(-0.05(0.05)0.3) ///
  xline(1(1)19, lwidth(thin) lcolor(gs8%30)) yline(-0.05(0.05)0.3, lwidth(thin) lcolor(gs8%30)) ///
  xlab(`var2values', valuelabels labsize(small)) ytitle("", size(small)) ytitle("Effect of compulsory schooling completion" "on support for trade", color(black) size(medium)) xtitle("Excluded country")



